<template>
	<view class="">
		<view class="nav_top-bg">
			<u-navbar title="评价">
				<view class="u-nav-slot" slot="left">
					<u-icon name="arrow-left" @click="go_black" size="19"></u-icon>
					<u-line direction="column" :hairline="false" length="16" margin="0 10px"></u-line>
					<u-icon name="home" @click="goHome" size="20"></u-icon>
				</view>
			</u-navbar>
		</view>
		<!-- 评论区域 -->
		<view class="pingfen">
			<view class="w-630">
				<view class="ping_fen-t" v-if="next_comment_count == 0">评分</view>
				<view class="" v-if="next_comment_count == 0">
					<u-rate :count="count" active-color="#FBA808" v-model="value"></u-rate>
				</view>
				<view class="ping_fen-t">评价</view>
				<view class="ping_fen-textarea">
					<textarea name="" placeholder="请输入..." v-model="pingjia" class="text-area" id="" cols="30" rows="10"></textarea>
				</view>
			</view>
		</view>
		<view class="foot_btn-but">
			<u-button text="提交评价" @click="submit_pingjia" shape="circle" size="large" color="#FF6400"></u-button>
		</view>
	</view>
</template>

<script>
	import {saveComment} from '@/api/user.js'
	export default {
		data(){
			return{
				count: 5,
				value: 0,
				pingjia:'',
				id:'',
				comment_id:'',
				next_comment_count:'',
			}
		},
		onLoad(option) {
			this.id = option.id
			this.next_comment_count = option.next_comment_count
			this.comment_id = option.comment_id
		},
		methods:{
			go_black() {
				uni.navigateBack({
					delta: 1
				})
			},
			goHome() {
				uni.switchTab({
					url: '/pages/index/index'
				})
			},
			// 提交评价
			submit_pingjia(){
				var data = {
					content_id: this.id,
					star: this.value,
					comment_id:this.comment_id,
					content: this.pingjia
				}
				saveComment(data).then(res => {
					console.log("评论回复保存",res);
					if(res.code == 1){
						if (typeof this.$util.prePage().get_pinglun_list == 'function') {
							this.$util.prePage().get_pinglun_list()
						}
						uni.navigateBack({
							delta: 1
						})
					}
				})
			},
		}
	}
</script>

<style>
	.foot_btn-but{
		width: 690rpx;
		margin: 90rpx auto;
	}
	.text-area{
		font-size: 28rpx;
		color: #333333;
		line-height: 40rpx;
		padding: 20rpx;
		background: #F6F6F6;
		border-radius: 10rpx;
	}
	.ping_fen-textarea{
		width: 610rpx;
		border-radius: 20rpx;
		padding-bottom: 30rpx;
	}
	.ping_fen-t{
		font-size: 28rpx;
		color: #333333;
		padding-top: 30rpx;
		margin-bottom: 30rpx;
	}
	.pingfen{
		width: 690rpx;
		border-radius: 8rpx;
		background: #FFFFFF;
		margin: 20rpx auto;
	}
	page {
		background-color: #F7F8FB;
	}
</style>